<!--
   /******************************************************************************
     Copyright:: 2020- IBM, Inc

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
  *****************************************************************************/
-->

<html lang="en-US">

<head>
    <title>ARIA Labels on label elements</title>
</head>

<body>
    <main>
        <div>
            <label for="pass1" aria-label="Pass1"></label>
            <input id="pass1" />
        </div>

        <div>
            <label for="fail1" aria-label=""></label>
            <input id="fail1" />
        </div>

        <div>
            <div id="labelpass2">Pass2</div>
            <label for="pass2" aria-labelledby="labelpass2"></label>
            <input id="pass2" />
        </div>

        <div>
            <div id="labelfail2"></div>
            <label for="fail2" aria-labelledby="labelfail2"></label>
            <input id="fail2" />
        </div>

        <div>
            <label for="pass3">Pass3</label>
            <input id="pass3" />
        </div>

        <div>
            <label for="fail3"></label>
            <input id="fail3" />
        </div>

    </main>
    <script type="text/javascript">
        UnitTest = {
            ruleIds: ["Valerie_Label_HasContent"],
            results: [
                {
                    "ruleId": "Valerie_Label_HasContent",
                    "value": [
                        "INFORMATION",
                        "PASS"
                    ],
                    "path": {
                        "dom": "/html[1]/body[1]/main[1]/div[1]/label[1]",
                        "aria": "/document[1]/main[1]"
                    },
                    "reasonId": "Pass_AriaLabel",
                    //"message": "LABEL element has accessible name via 'aria-label'",
                    "message": "<label> element has accessible name via 'aria-label'",
                    "messageArgs": [],
                    "apiArgs": [],
                    "category": "Accessibility"
                },
                {
                    "ruleId": "Valerie_Label_HasContent",
                    "value": [
                        "INFORMATION",
                        "FAIL"
                    ],
                    "path": {
                        "dom": "/html[1]/body[1]/main[1]/div[2]/label[1]",
                        "aria": "/document[1]/main[1]"
                    },
                    "reasonId": "Fail_1",
                    //"message": "LABEL element is missing descriptive text that identifies the expected input.",
                    "message": "The <label> element does not have descriptive text that identifies the expected input",
                    "messageArgs": [],
                    "apiArgs": [],
                    "category": "Accessibility"
                },
                {
                    "ruleId": "Valerie_Label_HasContent",
                    "value": [
                        "INFORMATION",
                        "PASS"
                    ],
                    "path": {
                        "dom": "/html[1]/body[1]/main[1]/div[3]/label[1]",
                        "aria": "/document[1]/main[1]"
                    },
                    "reasonId": "Pass_LabelledBy",
                    //"message": "LABEL element has accessible name via 'aria-labelledby'",
                    "message": "<label> element has accessible name via 'aria-labelledby'",
                    "messageArgs": [],
                    "apiArgs": [],
                    "category": "Accessibility"
                },
                {
                    "ruleId": "Valerie_Label_HasContent",
                    "value": [
                        "INFORMATION",
                        "FAIL"
                    ],
                    "path": {
                        "dom": "/html[1]/body[1]/main[1]/div[4]/label[1]",
                        "aria": "/document[1]/main[1]"
                    },
                    "reasonId": "Fail_1",
                    //"message": "LABEL element is missing descriptive text that identifies the expected input.",
                    "message": "The <label> element does not have descriptive text that identifies the expected input",
                    "messageArgs": [],
                    "apiArgs": [],
                    "category": "Accessibility"
                },
                {
                    "ruleId": "Valerie_Label_HasContent",
                    "value": [
                        "INFORMATION",
                        "PASS"
                    ],
                    "path": {
                        "dom": "/html[1]/body[1]/main[1]/div[5]/label[1]",
                        "aria": "/document[1]/main[1]"
                    },
                    "reasonId": "Pass_Regular",
                    //"message": "LABEL element has accessible name with inner content",
                    "message": "<label> element has accessible name with inner content",
                    "messageArgs": [],
                    "apiArgs": [],
                    "category": "Accessibility"
                },
                {
                    "ruleId": "Valerie_Label_HasContent",
                    "value": [
                        "INFORMATION",
                        "FAIL"
                    ],
                    "path": {
                        "dom": "/html[1]/body[1]/main[1]/div[6]/label[1]",
                        "aria": "/document[1]/main[1]"
                    },
                    "reasonId": "Fail_1",
                    //"message": "LABEL element is missing descriptive text that identifies the expected input.",
                    "message": "The <label> element does not have descriptive text that identifies the expected input",
                    "messageArgs": [],
                    "apiArgs": [],
                    "category": "Accessibility"
                }
            ]
        }
    </script>
</body>

</html>